package com.lb.jwitter.action;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;

import com.lb.jwitter.service.TblQLDTTXALichThiService;
import com.lb.jwitter.service.TblQuyenChiTietService;
import com.lb.jwitter.service.TblTaiKhoan;
import com.lb.jwitter.util.ApplicationContextProvider;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;

public class TblQLDTTXALichThiDeleteAction {
	private Long tblQLDTTXALichThiid; 
    public void setTblQLDTTXALichThiid(Long id) {
       this.tblQLDTTXALichThiid = id;
    }
    public Long getTblQLDTTXALichThiid() {
		return tblQLDTTXALichThiid;
	}
	
	
	private TblQLDTTXALichThiService tblQLDTTXALichThiService;
	
	
	private TblTaiKhoan taiKhoanDangNhap; 
    public TblTaiKhoan getTaiKhoanDangNhap() { 
        return taiKhoanDangNhap; 
    } 
    public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
        this.taiKhoanDangNhap = taiKhoanDangNhap; 
    } 
    private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
    ApplicationContextProvider contextProvider; 
public String execute() throws Exception 
{ 
	try{ 	
	     Map session = ActionContext.getContext().getSession();
	     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
	     if( taiKhoanDangNhap == null) return "noprivilege";
	    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
	    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
	    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_LichThi", "xoa")){ 
	        return "noprivilege"; 
	    }
	    tblQLDTTXALichThiService = (TblQLDTTXALichThiService) context.getBean("tbl_QLDTTXA_LichThiClient");
	    
	    tblQLDTTXALichThiService.deletetblQLDTTXALichThi(tblQLDTTXALichThiid);
        
	    
        return Action.SUCCESS; 
}
	catch(Exception e){ 
	      System.out.println("Loi Insert tbl_QLDTTXA_LichThi Action"); 
	     e.printStackTrace(); 
	    return Action.ERROR; 
	 } 
}
}
